﻿@{
    Layout = "~/Views/Shared/OA/_Index.cshtml";
}
@section Toolbar
{
    @Html.MyNet().Button(new ButtonOptions { Text = "上传", Click = "create" })
    @Html.MyNet().Button(new ButtonOptions { Text = "删除", Click = "removee", Icon = "remove" })
    @Html.MyNet().Button(new ButtonOptions { Text = "返回", Click = "back" })
}
@section Menu
{
    @Html.MyNet().Menu(new ButtonOptions { Text = "删除", Click = "removee", Icon = "remove" })
}
@section Main
{
    <div id="grid" class="grid">
    </div>
    <div id="pager" class="pager">
    </div>
}
@Html.Hidden("TypeKey", Request["TypeKey"])
<script>

    var typeKey = $("#TypeKey").val();
    var url = "/Common/Attachment/";


    jQuery(function ()
    {
        read();
    });

    function read()
    {
        query.typeKey = typeKey;

        $.ajax
        ({
            url: url + "ReadForType?VPartial=Read",
            data: query,
            type: "post",
            error: disposeError,
            success: function (result)
            {
                if (disposeException(result)) return;
                bind(result);
            }
        });
    }

    function create()
    {
        nav(url + "Create?TypeKey=" + typeKey);
    }

    function removee()
    {
        if (!gridSelected()) return alert("未选中任何数据！");
        if (!confirm("确定要删除选中的数据吗？")) return;

        $.ajax
        ({
            url: url + "RemoveForKey",
            data: { keys: gridSelected() },
            type: "post",
            error: disposeError,
            success: function (result)
            {
                if (disposeException(result)) return;
                read();
            }
        });
    }
   
</script>
